package tcards.android;

import models.Tcard;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;

public class GroupFieldList extends LinearLayout {
	private TextField   mLDW;
	private NumberField mNumPers;
	private NumberField mOrderNum;
	private TextField   mAgency;
	private TextField   mType;
	
	public GroupFieldList(Context context) {
		this(context, null, 0);
	}

	public GroupFieldList(Context context, AttributeSet attrs) {
		this(context, attrs, 0);
	}

	public GroupFieldList(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		LayoutInflater li = LayoutInflater.from(context);
		addView(li.inflate(R.layout.group_field_list, this, false));
		
		mLDW      = (TextField)   findViewById(R.id.ldwField);
		mNumPers  = (NumberField) findViewById(R.id.numPersField);
		mOrderNum = (NumberField) findViewById(R.id.orderNumField);
		mAgency   = (TextField)   findViewById(R.id.agencyField);
		mType     = (TextField)   findViewById(R.id.typeField);
	}
	
	public void setTcardFields(Tcard tcard) {
		tcard.setLDW(mLDW.getTextValue());
		tcard.setPersonnelCount(mNumPers.getNumberValue());
		tcard.setOrderNo(mOrderNum.getNumberValue());
		tcard.setAgency(mAgency.getTextValue());
		tcard.setType(mType.getTextValue());
	}
	
	public void setListFields(Tcard tcard) {
		mLDW.setTextValue(tcard.getLDW());
		mNumPers.setNumberValue(tcard.getPersonnelCount());
		mOrderNum.setNumberValue(tcard.getOrderNo());
		mAgency.setTextValue(tcard.getAgency());
		mType.setTextValue(tcard.getType());
	}
	
	public TextField getLDW() {
		return mLDW;
	}
	
	public NumberField getNumPers() {
		return mNumPers;
	}
	
	public NumberField getOrderNum() {
		return mOrderNum;
	}
	
	public TextField getAgency() {
		return mAgency;
	}
	
	public TextField getType() {
		return mType;
	}
}